package com.tim.app.ui.activity.person_center;

import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.support.v4.view.ViewPager;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageButton;

import com.application.library.widget.smarttab.SmartTabLayout;
import com.tim.app.R;
import com.tim.app.ui.activity.BaseActivity;
import com.tim.app.ui.adapter.TabAdapter;
import com.tim.app.ui.fragment.person.MyCollectAnswerFragment;
import com.tim.app.ui.fragment.person.MyCollectArticleFragment;
import com.tim.app.ui.fragment.person.MyCollectStoryFragment;


/**
 * 我的收藏页面
 */
public class MyCollectionActivity extends BaseActivity {

    public static final String TAG = "MyCollectionActivity";

    private ImageButton ibBack;

    private SmartTabLayout tab_layout;
    private ViewPager vpMyViewContent;
    private TabAdapter pageAdapter;

    public static void start(Context context) {
        Intent intent = new Intent(context, MyCollectionActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_my_collect;
    }


    @Override
    public void initView() {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        ibBack = (ImageButton) findViewById(R.id.ibBack);
        tab_layout = (SmartTabLayout) findViewById(R.id.tab_layout);
        vpMyViewContent = (ViewPager) findViewById(R.id.vpMyViewContent);

        ibBack.setOnClickListener(this);
        pageAdapter = new TabAdapter(getSupportFragmentManager());
        pageAdapter.addFragment(new MyCollectAnswerFragment(), getString(R.string.myCollectAnswer));
        pageAdapter.addFragment(new MyCollectArticleFragment(), getString(R.string.myCollectArtile));
        pageAdapter.addFragment(new MyCollectStoryFragment(), getString(R.string.myCollectStory));
        vpMyViewContent.setOffscreenPageLimit(3);
        vpMyViewContent.setAdapter(pageAdapter);
        vpMyViewContent.setCurrentItem(0);
        tab_layout.setViewPager(vpMyViewContent);
    }

    @Override
    public void initData() {
    }

    @Override
    protected void onResume() {
        super.onResume();
    }


    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ibBack://返回
                finish();
                break;
        }
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    }

}
